<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head>
    <th:block th:include="include :: header" />
    <th:block th:include="include :: bootstrap-switch-css" />
</head>
<body class="gray-bg">

<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            电梯名称：<input type="text" name="elevatorName"/>
                        </li>
                        <li>
                            使用单位：<input type="text" name="useUnit"/>
                        </li>

                        <li>
                            维保单位：<input type="text" name="maintenanceUnit"/>
                        </li>

                        <li>
                            电梯状态：
                            <select name="elevatorStatus" th:with="type=${@dict.getType('business_elevator_status')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </li>

                        <li>
                            联网状态：
                            <select  name="networkStatus">
                                <option value="">所有</option>
                                <option value="0">联网</option>
                                <option value="1">未联网</option>
                            </select>
                        </li>

                        <li>
                            检修：
                            <select  name="checkFix">
                                <option value="">所有</option>
                                <option value="0">开</option>
                                <option value="1">关</option>
                            </select>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<th:block th:include="include :: bootstrap-switch-js" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('business:elevatorInfo:edit')}]];
    var removeFlag = [[${@permission.hasPermi('business:elevatorInfo:remove')}]];
    var elevatorStatus = [[${@dict.getType('business_elevator_status')}]];
    var prefix = ctx + "business/elevatorInfo";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "电梯",
            search: false,
            showExport: true,
            columns: [{
                radio: true
            },
            {
                field: 'elevatorId',
                title: '电梯',
                visible: false
            },
            {
                title: "序号",
                formatter: function (value, row, index) {
                    return $.table.serialNumber(index);
                }
            },
            {
                field: 'registeredCode',
                title: '注册码',
                sortable: true
            },
            {
                field: 'elevatorName',
                title: '电梯名称',
                formatter: function (value, row, index) {
                    return addClick(value,row);
                }
            },
            {
                field: 'useUnit',
                title: '使用单位'
            },
            {
                field: 'maintenanceUnit',
                title: '维保单位'
            },
            {
                field: 'elevatorStatus',
                title: '电梯状态',
                formatter: function (value, row, index) {
                    return $.table.selectDictLabel(elevatorStatus, value);
                }
            },
            {
                field: 'checkFix',
                title: '检修',
                formatter: function (value, row, index) {
                    if (value == 0){
                        return "开"
                    }else if (value == 1){
                        return "关"
                    }
                }
            },
            {
                field: 'networkStatus',
                title: '联网状态',
                formatter: function(value, row, index) {
                    if (value == 0){
                        return "联网"
                    }else if (value == 1){
                        return "未联网"
                    }
                }
            }],
        };
        $.table.init(options);
    });


    function addClick(value,row) {
        return '<a href="javascript:void(0)" onclick="enable(\''+row.elevatorId + '\')">'+value+'</a>'
    }

    function enable(elevatorId) {
        createMenuItem(ctx+"business/elevatorInfo/elevatorBaseInfo/"+elevatorId,"电梯信息")
    }

</script>
</body>
</html>